// service/user_service/user_create.go
package user_service

import (
	"github.com/mojocn/base64Captcha"
	"muziai-server/global"
	"muziai-server/models/ctype"
)

func (u UserService) UserSendCode(rs ctype.RegisterSource, val string, templateID ctype.TemplateID) (code string, msg string) {
	code = base64Captcha.RandText(4, "0123456789")
	switch rs {
	case ctype.EmailRegister:
		msg = "验证码已发送至邮箱，请注意查收"
		tID := ""
		switch templateID {
		case ctype.RegisterTempalteID:
			tID = global.Config.Email.RegisterTemplate
		case ctype.BindAccountTemplateID:
			tID = global.Config.Email.BindTemplate
		}
		go u.EmailService.SendRegisterCode(tID, val, code)
	case ctype.TelRegister:
		//smsSer := sms.NewSMS()
		//msg = "验证码已发送至手机，请注意查收"
		//go smsSer.SendCode(val, code)
	}
	return
}
